<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TemplateArticulated</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] },
  TeX: { equationNumbers: { autoNumber: 'all' } }
});
</script>
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
body > * {
  max-width: 1000px;
}
body {
  font-family: "Roboto Condensed", sans-serif;
  padding-left: 7.5em;
  padding-right: 7.5em;
}
pre, code {
  max-width: 60em;
  font-family: monospace;
}
pre.oct-code {
  border: 1px solid Grey;
  padding: 5px;
}
pre.oct-code-output {
  margin-left: 2em;
}
span.comment {
  color: ForestGreen;
}
span.keyword {
  color: Blue;
}
span.string {
  color: DarkOrchid;
}
footer {
  margin-top: 2em;
  font-size: 80%;
}
a, a:visited {
  color: Blue;
}
h2 {
  font-family: "Roboto Condensed", serif;
  margin-top: 1.5em;
}
h2 a, h2 a:visited {
  color: Black;
}
</style>
</head>
<body>
<p><b>Defining parameters</b></p><pre class="oct-code"><span class="comment">% Choosing tire</span>
TireModel = TirePacejka();
TireModel.a0 = 1;
TireModel.a1 = 2;
TireModel.a2 = 700;
TireModel.a3 = 5000;
TireModel.a4 = 80;
TireModel.a5 = 0;
TireModel.a6 = 0;
TireModel.a7 = 0.6;

<span class="comment">% Choosing vehicle</span>
VehicleModel = VehicleArticulatedNonlinear();
VehicleModel.mF0 = 5200;
VehicleModel.mR0 = 2400;
VehicleModel.mF = 6000;
VehicleModel.mR = 10000;
VehicleModel.mM = 17000;
VehicleModel.IT = 46000;
VehicleModel.IS = 450000;
VehicleModel.lT = 3.5;
VehicleModel.lS = 7.7;
VehicleModel.c = -0.3;
VehicleModel.nF = 2;
VehicleModel.nR = 4;
VehicleModel.nM = 8;
VehicleModel.wT = 2.6;
VehicleModel.wS = 2.4;
VehicleModel.muy = 0.3;
VehicleModel.deltaf = 0;
VehicleModel.Fxf = 0;
VehicleModel.Fxr = 0;
VehicleModel.Fxm = 0;

<span class="comment">% The System is completely defined once we attribute the chosen tire model to the vehicle object.</span>
VehicleModel.tire = TireModel;</pre><p>Choosing simulation time span</p><pre class="oct-code">T = 7;                              <span class="comment">% Total simulation time [s]</span>
resol = 50;                         <span class="comment">% Resolution</span>
TSPAN = 0:T/resol:T;                <span class="comment">% Time span [s]</span>
</pre><p>To define a simulation object (simulator) the arguments must be the vehicle object and the time span.</p><pre class="oct-code">simulator = Simulator(VehicleModel, TSPAN);</pre><p>Changing initial conditions of the simulation object</p><pre class="oct-code">simulator.ALPHAT0 = 0.3;            <span class="comment">% Initial tractor side slip angle [rad]</span>
simulator.dPSI0 = 0.25;             <span class="comment">% Initial tractor yaw rate [rad/s]</span>
simulator.dPHI0 = 0.25;             <span class="comment">% Initial articulation rate [rad/s]</span>
</pre><p><b>Run simulation</b></p><p>To simulate the system we run the Simulate method of the simulation object.</p><pre class="oct-code">simulator.Simulate();</pre><p><b>Results</b></p><pre class="oct-code">g = Graphics(simulator);
g.TractorColor = <span class="string">'r'</span>;
g.SemitrailerColor = <span class="string">'g'</span>;
g.Frame();
g.Animation();</pre><img width="800" src="../illustrations/frame/TemplateArticulatedFrame.svg" alt="../illustrations/frame/TemplateArticulatedFrame.svg"><img src="../illustrations/animation/TemplateArticulatedAnimation.gif" alt="../illustrations/animation/TemplateArticulatedAnimation.gif">
<footer><hr><a href="http://www.octave.org">Published with GNU Octave 4.2.1</a></footer>
<!--
##### SOURCE BEGIN #####
%%
% *Defining parameters*

% Choosing tire
TireModel = TirePacejka();
TireModel.a0 = 1;
TireModel.a1 = 2;
TireModel.a2 = 700;
TireModel.a3 = 5000;
TireModel.a4 = 80;
TireModel.a5 = 0;
TireModel.a6 = 0;
TireModel.a7 = 0.6;

% Choosing vehicle
VehicleModel = VehicleArticulatedNonlinear();
VehicleModel.mF0 = 5200;
VehicleModel.mR0 = 2400;
VehicleModel.mF = 6000;
VehicleModel.mR = 10000;
VehicleModel.mM = 17000;
VehicleModel.IT = 46000;
VehicleModel.IS = 450000;
VehicleModel.lT = 3.5;
VehicleModel.lS = 7.7;
VehicleModel.c = -0.3;
VehicleModel.nF = 2;
VehicleModel.nR = 4;
VehicleModel.nM = 8;
VehicleModel.wT = 2.6;
VehicleModel.wS = 2.4;
VehicleModel.muy = 0.3;
VehicleModel.deltaf = 0;
VehicleModel.Fxf = 0;
VehicleModel.Fxr = 0;
VehicleModel.Fxm = 0;

% The System is completely defined once we attribute the chosen tire model to the vehicle object.
VehicleModel.tire = TireModel;

%%
% Choosing simulation time span

T = 7;                              % Total simulation time [s]
resol = 50;                         % Resolution
TSPAN = 0:T/resol:T;                % Time span [s]

%%
% To define a simulation object (simulator) the arguments must be the vehicle object and the time span.

simulator = Simulator(VehicleModel, TSPAN);

%%
% Changing initial conditions of the simulation object

simulator.ALPHAT0 = 0.3;            % Initial tractor side slip angle [rad]
simulator.dPSI0 = 0.25;             % Initial tractor yaw rate [rad/s]
simulator.dPHI0 = 0.25;             % Initial articulation rate [rad/s]

%%
% *Run simulation*
%
% To simulate the system we run the Simulate method of the simulation object.

simulator.Simulate();

%%
% *Results*
%

g = Graphics(simulator);
g.TractorColor = 'r';
g.SemitrailerColor = 'g';
g.Frame();
g.Animation();

%%
% <<../illustrations/frame/TemplateArticulatedFrame.svg>>
%
% <<../illustrations/animation/TemplateArticulatedAnimation.gif>>
%
##### SOURCE END #####
-->
</body>
</html>
